import {Config} from '../../utils/conf.js';
import {httpReq} from '../../utils/http.js';

class wans
{

  //提交函数
  saveinfo(that,qid, answer) {
    let obj = {};
    obj.url = Config.saveans;
    obj.method = 'post';
    obj.data = {
      uid:wx.getStorageSync('uid'),
      qid,
      answer
    };
    httpReq(obj).then(res => {
        if(res.data.state == 0){
          that.setData({
            com: ''
          })
          var qid = that.data.qid;
          var que = that.data.title;
          var con = that.data.content;
          var san = parseInt(that.data.ans) + 1;
          wx.showToast({
            title: '回答成功',
            icon: 'success',
          })
          setTimeout(()=>{wx.navigateTo({url: '/pages/info/info?qid=' + qid + '&que='+ que +'&con='+ con +'&aid=0&ans='+san})},3000);
        }else{
          wx.showToast({
            title: res.data.msg,
            icon: 'none',
          })
        }
    })
  }

  
}

export default wans;